feat: Add ability to selectively enable exporting of SDK internal metrics#5151
feat: Add ability to selectively enable exporting of SDK internal metrics#5151herin049 wants to merge 14 commits intoopen-telemetry:mainfrom
Conversation
MikeGoldsmith
left a comment
There was a problem hiding this comment.
Looks great, thanks @herin049.
It would be good to replace existing env var parsing with the new parse_boolean_environment_variable helper you've added in a follow-up PR.
…rics with the OTEL_PYTHON_SDK_METRIC_ENABLE environment variable
c224202 to
e528cde
Compare
There was a problem hiding this comment.
Cool. I was implementing this and just saw your PR today.
@herin049 wdyt to instead use the concept of a NoOpExporterMetrics? This way, we also avoid creating the instruments.
Something like:
class NoOpExporterMetrics:
@contextmanager
def export_operation(self, num_items: int) -> Iterator[ExportResult]:
yield ExportResult()
And from a factory, you check the env var
def create_exporter_metrics(signal, endpoint, meter_provider):
if not parse_boolean_environment_variable(
OTEL_PYTHON_SDK_INTERNAL_METRICS_ENABLED,
default=False,
):
return NoOpExporterMetrics()
return ExporterMetrics(signal, endpoint, meter_provider)
I'm ok with the env var name 👍🏻
Updated the PR based on the suggestions. I opted to keep environment variable parsing outside of the factory method to keep configuration separate from construction (and to prevent having to add |
tammy-baylis-swi
left a comment
There was a problem hiding this comment.
Good idea, thank you
Description
Adds ability to selectively enable/disable exporting of SDK internal metric collection with the introduction of the
OTEL_PYTHON_SDK_METRIC_ENABLEDenvironment variable.Motivation
While the "Stable by Default" OTEP has not been finalized yet, it is still preferrable to not emit unstable metric by default.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Contrib Repo Change?
Checklist: